//
//  HXSelectedTCell.m
//  ZCooking
//
//  Created by 韩旭 on 16/9/3.
//  Copyright © 2016年 HX_. All rights reserved.
//

#import "HXSelectedTCell.h"
#import "HXSelectedCCell.h"
#import "HX_Macro.h"
#import "HXMarowModel.h"
@implementation HXSelectedTCell
- (void)setMarrow:(NSMutableArray *)marrow {
    _marrow = marrow;
    [_collectionView reloadData];
}
- (void)setUp {
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.scrollDirection = 1;
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    _collectionView.showsHorizontalScrollIndicator = NO;
    _collectionView.bounces = NO;
    [self.contentView addSubview:_collectionView];
    [_collectionView registerNib:[UINib nibWithNibName:@"HXSelectedCCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"selectImage"];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.marrow.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HXSelectedCCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"selectImage" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    HXMarowModel *marow = self.marrow[indexPath.row];
    cell.backgroundColor = [UIColor whiteColor];
    [cell.cycleimage sd_setImageWithURL:[NSURL URLWithString:marow.image]];
    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    self.items(indexPath.row);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return 0;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return 0;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(self.collectionView.HX_width / 3.2, self.collectionView.HX_height);
}
- (void)layoutSubviews {
    self.collectionView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
}
@end